import { Address } from "@ton/core";

/**
 * 地址转hash 或者 hash转地址
 * @returns {string}
 * @param parse
 */
export const accountParse = (parse)=>{
    //判断是否是hash
    if(parse.length===66){
        // console.log(Address.parse(parse).toString()); // EQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPrHFэ
        // console.log(Address.parse(parse).toString({urlSafe: false})) // EQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff+W72r5gqPrHF
        // console.log(Address.parse(parse).toString({bounceable: false})) // UQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPuwA
        // console.log(Address.parse(parse).toString({testOnly: true})) // kQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPgpP
        // console.log(Address.parse(parse).toString({bounceable: false, testOnly: true})) // 0QDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPleK
      //是hash 则 hash转Address
      return Address.parse(parse).toString({bounceable: false});

    }
        console.log(Address.parse(parse).toRawString()); // EQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPrHFэ
        console.log(Address.parse(parse).toRawString({urlSafe: false})) // EQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff+W72r5gqPrHF
        console.log(Address.parse(parse).toRawString({bounceable: false})) // UQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPuwA
        console.log(Address.parse(parse).toRawString({testOnly: true})) // kQDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPgpP
        console.log(Address.parse(parse).toRawString({bounceable: false, testOnly: true})) // 0QDKbjIcfM6ezt8KjKJJLshZJJSqX7XOA4ff-W72r5gqPleK
    //否则地址转hash
     return  Address.parse(parse).toRawString();
}
